/**
 * 
 */
package com.huarui.component.action;

import java.util.Map;

import org.ewaf.framework.model.PagingInfo;

import com.huarui.component.service.TipsDataQuerier;
import com.huarui.component.service.TipsDataQuerierFactory;
import com.huarui.component.service.TipsDataType;
import com.opensymphony.xwork2.Action;

/**
 * @author peng.sunp
 * 
 */
public class CommonAutotipsorAction extends AbstractAutotipsorAction {

	private static final long serialVersionUID = 6207784652035367293L;
	private TipsDataType type; //查询的tips数据类型
	
	private PagingInfo<String,Map<String, Object>> jsonResult; // JSON Result默认读取jsonResult名称属性
	private TipsDataQuerierFactory tipsDataQuerierFactory;
	
	public String input() throws Exception {
		return Action.SUCCESS;
	}
	public String execute() throws Exception {
        System.out.println(this.type);
        this.jsonResult=new PagingInfo<String,Map<String, Object>>();
        this.jsonResult.setCondition(this.keyword);
        this.jsonResult.setStart((this.page-1)*this.size);
        this.jsonResult.setLimit(this.size);
		TipsDataQuerier querier = this.tipsDataQuerierFactory.getInstance(this.type);
		querier.queryTipsData(this.jsonResult);
		return Action.SUCCESS;
	}

	public void setTipsDataQuerierFactory(
			TipsDataQuerierFactory tipsDataQuerierFactory) {
		this.tipsDataQuerierFactory = tipsDataQuerierFactory;
	}

	public void setType(TipsDataType type) {
		this.type = type;
	}

	public PagingInfo<String,Map<String, Object>> getJsonResult() {
		return jsonResult;
	}

}
